<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
    <title>添加用户</title>
</head>
<body>
<div>
    传送的json数据格式：<br>
    {
    name:hugo,
    age:25
    }
</div>
<div>
    <button id="submitJson">提交JSON数据</button>
</div>

<br>

<div>
    返回的数据：<span id="result"></span>
</div>

<script>
    $(function () {
        $('#submitJson').click(function () {
            var user = {
                name: "hugo",
                age: "25"
            };

            $.ajax({
                type: "POST",
                url: "/user/save",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(user),
                dataType: "json",
                success: function (data) {
                    $('#result').html(data);
                }
            });

        });
    });
</script>
</body>
</html>